package com.agritech.service.impl;

import com.agritech.entity.Question;
import com.agritech.mapper.QuestionMapper;
import com.agritech.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 问题服务实现类
 */
@Service
public class QuestionServiceImpl implements QuestionService {
    
    @Autowired
    private QuestionMapper questionMapper;
    
    @Override
    public List<Question> getQuestionsByUserId(Long userID) {
        return questionMapper.selectByUserId(userID);
    }
    
    @Override
    public Question getQuestionById(Long id) {
        return questionMapper.selectById(id);
    }
    
    @Override
    public List<Question> getAllQuestions() {
        return questionMapper.selectAll();
    }
    
    @Override
    public boolean addQuestion(Question question) {
        int result = questionMapper.insert(question);
        return result > 0;
    }
    
    @Override
    public boolean updateQuestionStatus(Question question) {
        int result = questionMapper.updateStatus(question);
        return result > 0;
    }

    @Override
    public boolean deleteQuestionById(Long id) {
        return questionMapper.deleteById(id) > 0;
    }

}    